package com.zjw.jdbc.util;

import javax.sql.DataSource;

import net.sourceforge.groboutils.junit.v1.MultiThreadedTestRunner;
import net.sourceforge.groboutils.junit.v1.TestRunnable;

/**
 * grobo util test util
 * @author zjw
 *
 */
public class ThreadConnectionTestHelper {

	public static void groboTest(DataSource dataSource,long sleepMillis,int threadCount){
		
		RequestForConnectionRunner requestForConnection = new RequestForConnectionRunner(dataSource);
		requestForConnection.setSleepMillis(sleepMillis);//sleepTime
		
		TestRunnable [] trs = new TestRunnable[threadCount];
		for(int i=0;i<trs.length;i++){
			trs[i] = requestForConnection;
		}
		MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(trs);
		try {
			mttr.runTestRunnables();
		} catch (Throwable e) {
			e.printStackTrace();
		}
	}
}
